
package pl.wroc.uni.ii.evolution.objectivefunctions;

import pl.wroc.uni.ii.evolution.engine.individuals.EvRealVectorIndividual;
import pl.wroc.uni.ii.evolution.engine.prototype.EvObjectiveFunction;

/**
 * Computes sum of distance between individual and one (vector with one at each position).
 * 
 * @author Lukasz Witko, Tomasz Kozakiewicz
 * 
 */
public class EvRealOneMaxForStrategies<T extends EvRealVectorIndividual> implements
    EvObjectiveFunction<T> {

  private static final long serialVersionUID = -6895006014058153759L;

  public double evaluate( T individual ) {
    double sum = 0;
    for( int i = 0; i < individual.getDimension(); i++ ) {
      sum += Math.abs( individual.getValue( i ) - 1d );
    }
    return -sum;
  }

}
